


        function mergeBottomTables(confirm_tables, nonconfirm_tables, div_tables_id) {
            var table_text =    "<form name='time_form' id='time_form' action='' method='post'>"
            var form_confirm = new FormData('')
            var form_nonconfirm = new FormData('')
            table_text = confirm_tables.printBottomTable(table_text, form_confirm, 'Confirm List: ', 0, 'bottom_tables_confirm')
            table_text = nonconfirm_tables.printBottomTable(table_text, form_nonconfirm, 'Nonconfirm List: ', 1, 'bottom_tables_nonconfirm')
            if((form_confirm.time_id_list!='')||(form_nonconfirm.time_id_list!='')) {
                form_confirm.validatingForm()
                form_nonconfirm.validatingForm()
                table_text+=    "    <div class='HSpaceBeforeBottomTable '>" + 
                                "    </div>" + 
                                "    <div class='EmptyBlockBeforeTables'>" + 
                                "    </div>" + 
                                "    <div class='BaseForForm'>" + 
                                "        <input name='time_confirm_number' id='time_confirm_number' type='hidden' value='" + form_confirm.time_id_number + "'>" + 
                                "        <input name='time_nonconfirm_number' id='time_nonconfirm_number' type='hidden' value='" + form_nonconfirm.time_id_number + "'>" + 
                                "        <input name='time_id_confirm_list' id='time_id_confirm_list' type='hidden' value='" + form_confirm.time_id_list + "'>" + 
                                "        <input name='time_id_nonconfirm_list' id='time_id_nonconfirm_list' type='hidden' value='" + form_nonconfirm.time_id_list + "'>" + 
                                "        <div class='ConfirmButton'> <input onclick='' type='submit' value='Sent'> </div>" + 
                                "    </div>" + 
                                "</form>"
            }
            else {
                table_text+=    "</form>"
            }
            document.getElementById(div_tables_id).innerHTML = table_text
        }
        
        
        function printBottomTable(table_text, form, list_name, if_nonconfirm, node_name) {
            var table = this
            if(table.next_time!=null) {
                table_text+=    "<div class='HSpaceBeforeBottomTable '>" + 
                                "</div>" + 
                                "<div class='BottomTable'>" + 
                                "    <div class='EmptyBlockBeforeTables'>" + 
                                "    </div>" + 
                                "    <div class='BottomTableTitle'>" + 
                                         list_name + 
                                "    </div>" + 
                                "</div>"
            }
            while(table!=null) {
                if(table.next_time!=null) {
                    table_text+=    "<div class='HSpaceBeforeBottomTable '>" + 
                                    "</div>" + 
                                    "<div class='EmptyBlockBeforeTables'>" + 
                                    "</div>" + 
                                    "<div class='BottomTable'>" + 
                                    "    <div class='TimeTableLine'>" + 
                                    "        project:->" + table.project_name + "      user:->" + table.user_name + 
                                    "    </div>" + 
                                    "    <div class='TimeTableLine'>" + 
                                    "        <div class='TimeTableBottomTitleDate'>" + 
                                    "            <center> Date </center>" + 
                                    "        </div>" + 
                                    "        <div class='TimeTableBottomTitleActivity'>" + 
                                    "            <center> Activity </center>" + 
                                    "        </div>" + 
                                    "        <div class='TimeTableBottomTitleTime'>" + 
                                    "            <center> Time </center>" + 
                                    "        </div>" + 
                                    "        <div class='TimeTableBottomTitleDetails'>" + 
                                    "            <center> Details </center>" + 
                                    "        </div>" + 
                                    "    </div>"
                    table_text = table.printBottomLine(table_text, form, if_nonconfirm)
                    table_text+=    "    <div class='TimeTableLine'>" + 
                                    "        <div class='ConfirmButton'> <button onclick='" + node_name + ".rollBackTimeList(project_user_tables), printTime(project_user_tables, project_select.id_field, user_select.id_field, " + '"div_time_table"' + "), mergeBottomTables(bottom_tables_confirm, bottom_tables_nonconfirm, " + '"div_bottom_tables"' + ")' type='button'>Roll Back</button> </div>" + 
                                    "    </div>" + 
                                    "</div>"
                }
                table = table.next_time_node
                node_name+= '.next_time_node'
            }
            return table_text
        }
        
        function printBottomLine(table_text, form, if_nonconfirm) {
            var time_temp
            var is_first = 1
            time_temp = this.next_time
            while(time_temp!=null) {
                if((if_nonconfirm==1)&&(is_first==0)) {
                    table_text+="    <div class='TimeTableLine'>" + 
                                "        <div class='TimeTableBottomTitleDate'>" + 
                                "            <center> Date </center>" + 
                                "        </div>" + 
                                "        <div class='TimeTableBottomTitleActivity'>" + 
                                "            <center> Activity </center>" + 
                                "        </div>" + 
                                "        <div class='TimeTableBottomTitleTime'>" + 
                                "            <center> Time </center>" + 
                                "        </div>" + 
                                "        <div class='TimeTableBottomTitleDetails'>" + 
                                "            <center> Details </center>" + 
                                "        </div>" + 
                                "    </div>"
                }
                table_text+=    "<div class='TimeTableLine'>" + 
                                "    <div class='TimeTableBottomDate'>" + 
                                        time_temp.field_date + 
                                "    </div>" + 
                                "    <div class='TimeTableBottomActivity'>" + 
                                        time_temp.field_activity + 
                                "    </div>" + 
                                "    <div class='TimeTableBottomTime'>" + 
                                        time_temp.field_time + 
                                "    </div>" + 
                                "    <div class='TimeTableBottomDetails'>" + 
                                        time_temp.field_details + 
                                "    </div>" + 
                                " </div>"   
                if(if_nonconfirm==1) {
                    is_first = 0
                    table_text+=    "<div class='TimeTableLine'>" + 
                                    "    comments:" + 
                                    "    <input name='comments_" + form.time_id_number + "' id='comments_" + form.time_id_number + "' type='text' size='80' value=''>" + 
                                    "    <input name='time_id_nonconfirm_" + form.time_id_number + "' id='time_id_nonconfirm_" + form.time_id_number + "' type='hidden' value='" + time_temp.time_id + "'>" + 
                                    "    <input name='time_nonconfirm_" + form.time_id_number + "' id='time_nonconfirm_" + form.time_id_number + "' type='hidden' value='" + time_temp.field_time + "'>" + 
                                    "</div>"
                }
                else {
                    table_text+=    "<input name='time_id_confirm_" + form.time_id_number + "' id='time_id_confirm_" + form.time_id_number + "' type='hidden' value='" + time_temp.time_id + "'>" + 
                                    "<input name='time_confirm_" + form.time_id_number + "' id='time_confirm_" + form.time_id_number + "' type='hidden' value='" + time_temp.field_time + "'>"
                }
                form.time_id_list+= time_temp.time_id + ','  
                form.time_id_number+= 1                
                time_temp = time_temp.next_time
            }
            return table_text
        }
        
        function rollBackTimeList(project_user_node) {
            if((project_user_node!=null)&&(this!=null)) {
                var user_search_result = project_user_node.searchTime(this.project_id, this.user_id)
                if(user_search_result!=null) {
                    var user_search_result_temp = user_search_result
                    while(user_search_result_temp.next_time!=null) {
                        user_search_result_temp = user_search_result_temp.next_time
                    }
                    user_search_result_temp.next_time = this.next_time
                    this.next_time = null
                }
                else {
                    var error_report = 'Error #2: user_search_result = null'
                    return error_report
                }
            }
            else {
                var error_report = 'Error #1: one of input lists is equal to null'
                return error_report
            }
        }
        
        function BottomTimeFieldNode(in_user_id, in_user_name, in_project_id, in_project_name) {
            this.user_id = in_user_id
            this.user_name = in_user_name
            this.project_id = in_project_id
            this.project_name = in_project_name
            this.next_time = null
            this.next_time_node = null
            
            this.printBottomLine = printBottomLine
            this.printBottomTable = printBottomTable
            this.rollBackTimeList = rollBackTimeList
        }
        
        
        function validatingForm() {
            var del_fix_pattern = new RegExp('[^ ]*(?=,$)')
            var validating_pattern = new RegExp('([0-9]+,)+')
            var validated_text
            if((this.time_id_list!='')&&(this.time_id_number > 0)) {
                if((del_fix_pattern.test(this.time_id_list))&&(validating_pattern.test(this.time_id_list))) {
                    if((String(this.time_id_list).match(del_fix_pattern)[0]+',')==String(this.time_id_list).match(validating_pattern)[0]) {
                        this.time_id_list = String(this.time_id_list).match(del_fix_pattern)[0]
                        this.state = 'valid'
                        return 'ok!'
                    }
                    else {
                        var error_report = 'Error #3: time_id_list=' + this.time_id_list + ' is out of range'
                        this.time_id_list = ''
                        this.state = error_report
                        return error_report
                    }
                }
                else {
                    var error_report = 'Error #2: time_id_list=' + this.time_id_list + ' is out of range'
                    this.time_id_list = ''
                    this.state = error_report
                    return error_report
                }
            }
            else {
                var error_report = 'Error #1: time_id_list is empty or number of records is out of range'
                this.state = error_report
                return error_report
            }
        }
        
        function FormData(in_time_id_list) {
            this.time_id_list = in_time_id_list
            this.time_id_number = 0
            this.state = 'invalid'
            
            this.validatingForm = validatingForm
        }
        
        var bottom_tables_confirm = new BottomTimeFieldNode(-1, ' ', -1, ' ')
        var bottom_tables_nonconfirm = new BottomTimeFieldNode(-1, ' ', -1, ' ')
        
        